package com.aspose.cells;

import java.io.OutputStream;

public class Sparkline {
   private SparklineCollection a;
   private zboa b;
   private int c;
   private short d;

   Sparkline(SparklineCollection sparklines) {
      this.a = sparklines;
   }

   zboa a() {
      return this.b;
   }

   public String getDataRange() {
      return this.b == null ? null : zase.H(this.b.a());
   }

   public void setDataRange(String value) {
      if (value != null && !"".equals(value)) {
         Worksheet var2 = this.a.a().a().a();
         this.b = new zboa(var2);
         this.b.a(value);
         this.b.c();
         if (this.b.e == this.b.g) {
            if (this.b.j != this.b.k) {
               throw new CellsException(14, "The reference for the data range is invalid");
            }
         } else {
            if (this.b.d != this.b.f) {
               throw new CellsException(14, "Data range cells must in same column or row");
            }

            if (this.b.h != this.b.i) {
               throw new CellsException(14, "The reference for the data range is invalid");
            }
         }

      } else {
         this.b = null;
      }
   }

   zbob[] b() {
      return this.b != null ? this.b.b() : null;
   }

   public int getRow() {
      return this.c;
   }

   void a(int var1) {
      this.c = var1;
   }

   public int getColumn() {
      return this.d;
   }

   void b(int var1) {
      this.d = (short)var1;
   }

   private int e() {
      return this.a.a().a().a().getCells().getColumnWidthPixel(this.d);
   }

   private int f() {
      return this.a.a().a().a().getCells().getRowHeightPixel(this.c);
   }

   boolean c() {
      return this.e() > 0 && this.f() > 0;
   }

   public void toImage(String fileName, ImageOrPrintOptions options) throws Exception {
      if (options == null) {
         options = new ImageOrPrintOptions();
      }

      if (this.c()) {
         zbuk.a(fileName, options);
         com.aspose.cells.b.a.d.ze var3 = new com.aspose.cells.b.a.d.ze(fileName, 2);

         try {
            this.a((com.aspose.cells.b.a.d.zm)var3, (ImageOrPrintOptions)options);
         } finally {
            if (var3 != null) {
               var3.a();
            }

         }
      }

   }

   void a(com.aspose.cells.b.a.d.zm var1, ImageOrPrintOptions var2) throws Exception {
      if (this.c()) {
         com.aspose.cells.a.d.zb var3 = this.d();
         zbuk.a(var1, var3, var2, this.e(), this.f());
      }
   }

   public void toImage(OutputStream stream, ImageOrPrintOptions options) throws Exception {
      com.aspose.cells.b.a.d.zh var3 = new com.aspose.cells.b.a.d.zh();
      this.a((com.aspose.cells.b.a.d.zm)var3, (ImageOrPrintOptions)options);
      var3.a(0L, 0);
      var3.a(stream);
   }

   com.aspose.cells.a.d.zb d() {
      zjk var1 = new zjk(this.a.a(), this.b(), this.e(), this.f());
      var1.b();
      return var1.a();
   }

   boolean a(CellArea var1) {
      return this.c >= var1.StartRow && this.c <= var1.EndRow && this.d >= var1.StartColumn && this.d <= var1.EndColumn;
   }

   boolean a(Cells var1, int var2, int var3, boolean var4) {
      if (var3 < 0 && this.c >= var2 && this.c < var2 - var3) {
         return true;
      } else {
         int var5 = this.c;
         if (var4 && this.c >= var2) {
            this.c += var3;
         }

         int var6 = this.c;
         if (this.b.c.equals(var1.h().getName())) {
            if (this.b.d >= var2 && this.b.f < var2 - var3) {
               return true;
            }

            this.b.d += var3;
            this.b.f += var3;
            if (this.b.a != null) {
               zyo.a(var1.h(), var4, var2, var3, var5, var6, -1, -1, this.b.a);
            }
         }

         return false;
      }
   }

   boolean b(Cells var1, int var2, int var3, boolean var4) {
      if (var3 < 0 && this.d >= var2 && this.d < var2 - var3) {
         return true;
      } else {
         short var5 = this.d;
         if (var4 && this.d >= var2) {
            this.d += (short)var3;
         }

         short var6 = this.d;
         if (this.b.c.equals(var1.h().getName())) {
            if (this.b.e >= var2 && this.b.g < var2 - var3) {
               return true;
            }

            this.b.e += var3;
            this.b.g += var3;
            if (this.b.a != null) {
               zyo.c(var1.h(), var4, var2, var3, var5, var6, -1, -1, this.b.a);
            }
         }

         return false;
      }
   }

   void a(Sparkline var1, CopyOptions var2) {
      this.d = var1.d;
      this.c = var1.c;
      if (var1.b != null) {
         this.b = new zboa(this.a.b());
         if (!var2.a) {
            this.b.a = zyd.a(var1.a.c(), this.a.c(), var1.b.a, -1, 0, 0);
            this.setDataRange(var1.getDataRange());
            if (!zyo.a(var2.i, var2.d, var1.a.b(), this.a.b(), var2.k, var2.j, -1, -1, this.b.a)) {
               this.b = null;
            }
         } else {
            this.b.a = zyd.a(var1.a.c(), this.a.c(), var1.b.a, -1, 0, 0);
            this.b.a(var1.b, var2);
         }
      }

   }

   void a(Sparkline var1, boolean var2, int var3, int var4, int var5, CopyOptions var6) {
      this.d = var1.d;
      this.c = var1.c;
      int var7 = var4 - var3;
      if (var2) {
         this.c = var1.c + var7;
      } else {
         this.d = (short)(var1.d + var7);
      }

      if (var1.b != null) {
         this.b = new zboa(this.a.b());
         if (!var6.a) {
            this.b.a = zyd.a(var1.a.c(), this.a.c(), var1.b.a, -1, 0, 0);
            this.setDataRange(var1.getDataRange());
            if (!zyo.a(var6.i, var6.d, var1.a.b(), this.a.b(), var6.k, var6.j, -1, -1, this.b.a)) {
               this.b = null;
            }
         } else {
            this.b.a = zyd.a(var1.a.c(), this.a.c(), var1.b.a, -1, 0, 0);
            this.b.a(var1.b, var6);
         }

         if (var2) {
            zyo.a(this.a.c(), var3, var7, var1.c, 0, 0, 0, this.b.a, -1, -1);
         } else {
            zyo.a(this.a.c(), 0, 0, 0, var3, var7, var1.d, this.b.a, -1, -1);
         }
      }

   }
}
